package org.example.clouddemo.recommend.controller.app;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.example.clouddemo.recommend.service.common.RecommendService;
import org.example.clouddemo.bean.common.entity.Product;
import org.example.common.annotation.IgnoreAuth;
import org.example.common.response.ApiResult;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(tags = "推荐接口")
@ApiSupport(order = 1)
@RequiredArgsConstructor
@RestController("appRecommendController")
@RequestMapping("/api/app/recommend")
public class RecommendController {

    private final RecommendService recommendService;

    @ApiOperation(value = "基于id的推荐列表", notes = "不需要token")
    @PostMapping("list/{userid}")
    @IgnoreAuth
    public ApiResult<List<Product>> list(@PathVariable("userid") Long userid) {
        List<Product> result = recommendService.recommendProductListByUserId(userid);
        return ApiResult.success(result);
    }

//    @ApiOperation(value = "推荐列表", notes = "不需要token")
//    @PostMapping("list/{page}/{pageSize}")
//    @IgnoreAuth
//    public ApiResult<IPage<Product>> list(@PathVariable("page") int page, @PathVariable("pageSize") int pageSize) {
//        Page<Product> pageInfo = new Page<>(page,pageSize);
//        IPage<Product> result = recommendService.recommendProductList(pageInfo);
//        return ApiResult.success(result);
//    }
//
//    @ApiOperation(value = "根据订单推荐", notes = "内部接口，不直接对外")
//    @PostMapping("list-by-order/{page}/{pageSize}")
//    public ApiResult<IPage<Product>> listByOrder(
//            @PathVariable("page") int page,
//            @PathVariable("pageSize") int pageSize,
//            @RequestBody Order order
//    ) {
//        // 构建分页参数
//        Page<Product> pageInfo = new Page<>(page, pageSize);
//
//        // 调用服务方法获取推荐结果
//        IPage<Product> result = recommendService.recommendProductListByOrder(pageInfo, order);
//
//        return ApiResult.success(result);
//    }
}
